package com.csht.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csht.model.City;
import com.csht.model.CshtBrand;
import com.csht.model.CshtGoods;
import com.csht.model.CshtGoodsImages;
import com.csht.model.CshtOneMenu;
import com.csht.model.CshtThreeMenu;
import com.csht.model.CshtTwoMenu;
import com.csht.model.Province;
import com.csht.model.School;
import com.csht.service.CshtBrandService;
import com.csht.service.CshtGoodsImagesService;
import com.csht.service.CshtGoodsService;
import com.csht.service.CshtOneMenuService;
import com.csht.service.CshtThreeMenuService;
import com.csht.service.CshtTwoMenuService;
import com.csht.service.IndexService;
import com.csht.service.ReleaseGoodsService;
import com.csht.vo.goods.ThreeMenuVo;

/**
 * 发布商品service
 * @author chenhuiyan
 *
 */
@Service
public class ReleaseGoodsServiceImpl implements ReleaseGoodsService {

	@Autowired
	private CshtOneMenuService cshtOneMenuService;
	
	@Autowired
	private CshtTwoMenuService cshtTwoMenuService;
	
	@Autowired
	private CshtThreeMenuService cshtThreeMenuService;
	
	@Autowired
	private CshtBrandService cshtBrandService;
	
	@Autowired
	private IndexService indexService;
	
	@Autowired
	private CshtGoodsService cshtGoodsService;
	
	@Autowired
	private CshtGoodsImagesService cshtGoodsImagesService;
	
	/**
	 * 查询全部一级菜单
	 */
	@Override
	public List<CshtOneMenu> getAllOneMenu() throws Exception {
		List<CshtOneMenu> cshtOneMenuList = cshtOneMenuService.getAllOneMenu();
		return cshtOneMenuList;
	}

	/**
	 * 根据一级菜单查询二级菜单
	 */
	@Override
	public List<CshtTwoMenu> getTowMenuByOneMenuId(Integer oneMenuId) throws Exception {
		List<CshtTwoMenu> cshtTwoMenuList = cshtTwoMenuService.getTwoMenuByOneMenuId(oneMenuId);
		return cshtTwoMenuList;
	}

	/**
	 * 根据二级菜单id查询三级菜单
	 */
	@Override
	public List<CshtThreeMenu> getThreeMenuByTwoMenuId(Integer twoMenuId) throws Exception {
		List<CshtThreeMenu> cshtThreeMenuList = cshtThreeMenuService.getThreeMenu(twoMenuId);
		return cshtThreeMenuList;
	}
	
	/**
	 * 根据一级菜单id查找品牌
	 * @param oneMenuId
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<CshtBrand> getBrandByOneMenuId(Integer oneMenuId) throws Exception{
		List<CshtBrand> cshtBrandList = cshtBrandService.getAllBrand(oneMenuId);
		return cshtBrandList;
	}

	/**
	 * 获取全部省份
	 */
	@Override
	public List<Province> getAllProvince(String provinceUrl) throws Exception {
		List<Province> provinceList = indexService.getAllProvince(provinceUrl);
		return provinceList;
	}

	/**
	 * 根据省id获取该省全部城市
	 */
	@Override
	public List<City> getAllCityByProvinceId(String cityUrl, Integer provinceId) throws Exception {
		List<City> cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
		return cityList;
	}

	/**
	 * 根据城市名获取学校
	 */
	@Override
	public List<School> getAllSchoolByCityName(String schoolUrl, String cityName) throws Exception {
		List<School> schoolList = indexService.getAllSchoolByCityName(schoolUrl, cityName);
		return schoolList;
	}

	/**
	 * 模糊搜索三级菜单
	 */
	@Override
	public List<ThreeMenuVo> getMenuToSearch(String threeMenuName) throws Exception {
		List<ThreeMenuVo> threeMenuVoList = cshtThreeMenuService.getMenuToSearch(threeMenuName);
		return threeMenuVoList;
	}

	/**
	 * 添加商品并返回主键id
	 */
	@Override
	public void insertGoods(CshtGoods cshtGoods) throws Exception {
		cshtGoodsService.insertGoods(cshtGoods);
	}
	
	/**
	 * 更新商品封面图
	 */
	@Override
	public void updateGoodsImapath(CshtGoods cshtGoods) throws Exception {
		cshtGoodsService.updateGoodsImapath(cshtGoods);
	}
	
	/**
	 * 添加商品图 
	 */
	@Override
	public void insertGoodsImages(CshtGoodsImages cshtGoodsImages) throws Exception {
		cshtGoodsImagesService.insertGoodsImages(cshtGoodsImages);
	}
	
}
